//
//  ViewController.swift
//  randomColor
//
//  Created by 李煜 on 2024/3/28.
//

import UIKit

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()

    let aView = UIView(frame: CGRect(x: 100, y: 100, width: 100, height: 100))
    view.addSubview(aView)

    aView.backgroundColor = randomColor()
  }
  // MARK: - 随机色 新API
  func randomColor()->UIColor {
    let r = CGFloat.random(in: 0...1)
    let g = CGFloat.random(in: 0...1)
    let b = CGFloat.random(in: 0...1)
    return UIColor(red: r, green: g, blue: b, alpha: 1)
  }

}

